<!DOCTYPE html>




<html class="theme-next pisces" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">






  
  
  <link rel="stylesheet" media="all" href="/lib/Han/dist/han.min.css?v=3.3">




<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



  <meta name="google-site-verification" content="9KSJHwRk-w65aBEuVrJHaNkOSgPnak9oIC4bpY7OIj8" />














  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />





  <link rel="alternate" href="/atom.xml" title="kZime's blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/images/l.png?v=5.1.2" />






<meta name="description" content="我与我仍要大战三百回合, 闲杂人等都给我退后">
<meta property="og:type" content="website">
<meta property="og:title" content="kZime&#39;s blog">
<meta property="og:url" content="http://kzime.xyz/page/2/index.html">
<meta property="og:site_name" content="kZime&#39;s blog">
<meta property="og:description" content="我与我仍要大战三百回合, 闲杂人等都给我退后">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="kZime&#39;s blog">
<meta name="twitter:description" content="我与我仍要大战三百回合, 闲杂人等都给我退后">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.2',
    sidebar: {"position":"left","offset":12,"offset_float":12,"b2t":true,"scrollpercent":true,"onmobile":true},
    fancybox: true,
    tabs: true,
    motion: {"enable":false,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://kzime.xyz/page/2/"/>





  <title>kZime's blog</title>
  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', 'xxx', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?7f98f1f8c73489fb85b3d53df668e211";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">kZime's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">kZime</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="st-search-show-outputs">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <form class="site-search-form">
  <input type="text" id="st-search-input" class="st-search-input st-default-search-input" />
</form>

<script type="text/javascript">
  (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
    (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
    e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
  })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

  _st('install', 'xxx','2.0.0');
</script>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://kzime.xyz/2017/05/04/hello-world/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kZime">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/l.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kZime's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/05/04/hello-world/" itemprop="url">博客重建</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-04T16:42:26+08:00">
                2017-05-04
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/blog/" itemprop="url" rel="index">
                    <span itemprop="name">blog</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/05/04/hello-world/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2017/05/04/hello-world/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <p>因为自己乱搞Ubuntu，在Ubuntu下进行了一些类似于  </p>
<blockquote>
<p>cd /<br>sudo rm -rf</p>
</blockquote>
<p>的错误操作，<br>导致Ubuntu系统崩盘，顺带清了一个盘<br>甚至电脑启动不了了几次<br>磁盘恢复就恢复出来几篇文章，剩下的还有自己去网上抠。。<br>惨死。。</p>
<p>嗯，就假装是一次博客升级吧，恢复文章的过程还顺便去fock了别人的一个主题，<br>估计是码代码时候熟悉黑色背景了，这款主题也是看着很舒服，也算很开心吧。<br>这次集训我在课余时间重装了数十次Ubuntu，虽然很崩溃吧，但是学到了很多， 还搞到了一个非常爽的编辑器<strong><em>atom</em></strong>， 强推。<br><strong><em>震惊！kZime看了之后连Vim都弃了！  </em></strong></p>
<p>就是这种感觉。 Vim虽然有着很棒的码代码的手感，但编译，调试时甚是麻烦，而且代码补全插件我一直搞不好qwq，就很气，但<strong><em>atom</em></strong>不仅手感好，各种插件也做的很方便。有一个小细节我要点个赞，之前不管是devc还是vim，关于编码方面都处理的不是太好，vim还行，认死一个UTF-8就够了，但devc会把UTF-8的代码注释弄成乱码，在devc是的代码注释移动到vim又成乱码了，notepad++在这块做的还好，至少可以很方便的转换编码。<strong><em>atom</em></strong>而可以直接在编辑器右下角调成自动选择编码模式，这样就很爽了。而且atom作为github的产品，开源免费是必须的，还可以直接在atom呢下载github上的插件，主题。vim模式插件不用说，连Emacs插件也有。还有强大的自定义功能，加上几个插件， 就可以说是IDE了。</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://kzime.xyz/2017/04/22/HAOI2017/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kZime">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/l.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kZime's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/04/22/HAOI2017/" itemprop="url">HAOI2017游记</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-04-22T08:18:51+08:00">
                2017-04-22
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/04/22/HAOI2017/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2017/04/22/HAOI2017/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <p>OI生涯经历的第一场省选，惨烈无比<br>纪念syz18界学长 XTT, TYS, DCH<br>ssy18界学长学姐 MK, KZNS, 农场主， 克泽风，</p>
<hr>
<h3 id="DAY-7"><a href="#DAY-7" class="headerlink" title="DAY -7"></a>DAY -7</h3><p>  周日和一群dalao去参加轻院校赛，和wb，学长tys一队，队名很鬼畜。<br>  开考读题，直接把一道看上去很水的最短路D递给tys了，然后wb继续看题，我看着tys码spfa，感觉没什么问题犹豫了一下，提交了，直接RE，开门GG，心态全无，感觉是边数开小了，又交了一次，仍然RE。。慌得直接换题。然后我和wb讨论A题的三维坐标下点到直线的距离，推广不出来。换题，看到E题以为是个很简单的贪心，交给tys，打着打着突然感觉不对劲，少考虑好多影响（结束后问了才知道是个网络流。。。，考试中间评测服务器掉线，写了4道题，服务器上线后交完连WA带TLE加RE。。最后只A了两道题，带着狗牌走掉。天天队伍A了8道题，拿到了rk3，一中mjl两人队A8题rk2，mjl太强了aaaa…离开的时候发誓明年再来参加一定AK全场。<br>  比完赛跟着天天，省实验的人，一中的mjl去吃饭，看速8，然后跟ldl，KZ坐出租回家</p>
<h3 id="DAY-6-3"><a href="#DAY-6-3" class="headerlink" title="DAY -6 ~ -3"></a>DAY -6 ~ -3</h3><p>  在省实验集训，每天上午都在实验内网考试，考到中文12点， 然后我就会和wb一起去学校对面碰碰凉要不是玩王者农药，要不是码代码，平均一次A一道最水的题吧。。考完两天突然把比赛放在192.168.1.12上了，用账户条登陆。然后就体验到省实验著名的颓废机房（233。老师讲的东西基本上听不懂。。。<br>  每天晚上10点去实验操场找粽子，和她散散步，聊聊天。。。开心</p>
<h3 id="DAY-2-1"><a href="#DAY-2-1" class="headerlink" title="DAY -2 ~ -1"></a>DAY -2 ~ -1</h3><p>  白天日常，晚上刷CF，见前一篇博客。然后睡在机房，睡前和mk，zf聊了很多人，很多事，mk睡之前确定的说，感觉自己还是有很大机会进队的，自己很自信自己的水平。我们也希望mk能进队。<br>  日常，不过没比赛，今天wb没来实验，我写了写水题就跟着大家浮了起来，下午，机房里的人都去看考场或者订宾馆了，我见人少，就回家了。</p>
<h3 id="DAY-0上午"><a href="#DAY-0上午" class="headerlink" title="DAY 0上午"></a>DAY 0上午</h3><p>  早上去郑大找不到考场在哪，转了好几圈，我qq问mjl知道不知道在哪，他也表示懵逼。然后突然在路上发现一只野生的天天，就直接跟着他跑了，找到之后给mjl说考场在哪。（后来看他博客知道他是考前5分钟进的考场。<br>  到考场时已经有点晚了，赶快准备准备环境，安装安装IDE， 突然在D盘资源文件夹里看到了个smartc。我直接喊了一句woc，这玩意我前天在省实验集训的时候才在网上见过，内含各种模板，之前我还玩了半天模板里的游戏。我打开翻了翻，发现里面的代码模板没有被清除，立马预见到这次HAOI又改有问题了。。<br>  t1刚拿到的时候感觉是跟强连通分量，双联通分量什么的有关，但又没思路，就直接码暴力。码到一半脑补出了一个我解决不了的样例，对暴力的正确性产生了怀疑。然后直接放弃，t2直接按照题面意思码一个暴力出来。t3有3种操作，其中只有第一种操作就能过6个点，当时时间也不太够了，直接码起异或版spfa。但是因为样例抄错了耽误了很多时间。码完还剩两分钟玩起了smartc里的俄罗 斯方块。</p>
<h3 id="DAY-0下午"><a href="#DAY-0下午" class="headerlink" title="DAY 0下午"></a>DAY 0下午</h3><p>  出来之后表示大家写的都是暴力，心态还好。但是TYS专注码t2后缀数组，因为记错一个变量名爆零，其它题一点没码。听我说smartc上有后缀数组的模板后直接个ccf发了封邮件。<br>  下午t1看出来是个DP了，但是题面看不太明白，就先把t2的20分暴力码了，然后t1还是看不懂，就各种玩。电脑里有啥玩啥。<br>  考完mk说感觉自己要擦线进队了。<br>  天天，sxy和杨老师留在那等结果，我们直接回学校，回家。<br>  回家睡到7点回学校。</p>
<h3 id="DAY-1"><a href="#DAY-1" class="headerlink" title="DAY 1"></a>DAY 1</h3><p>  空间被mjl刷屏了，似乎评测用的lemon内存设置出问题了，好多人mle掉。又有人说下午t1数据太水，不考虑障碍情况的裸dp就过了8个点，然后这几天就各种申诉。在学校学文化课，偶尔会机房码题。</p>
<h3 id="DAY-3"><a href="#DAY-3" class="headerlink" title="DAY 3"></a>DAY 3</h3><p>  成绩出了mjl rk3强势进队，焦作一中进来3个，安阳一中进了2个，郑州一中进了2个。郑州一中的两个里还都是高一的。Rapiz被学弟擦线挤出队，rk8。省实验没有进队，其中农场主考的最高，mk也没有成功。。<br>  zsb下午t1裸dp过了8个点，120分，sxydalao110分，不知道会不会买D进队，TYS上午爆零，下午拿了90分，拿到一等，我60分，rk23，差1个点一等。。。wb，wzz爆零，天天学长。。爆零。<br>  不知道为什么，本来最有希望，最强的天天爆零了。好像因为函数名写错，文件读入输出写错。。。但感觉好可惜。<br>  然后后面的几天都没看到天天。</p>
<h3 id="DAY-5"><a href="#DAY-5" class="headerlink" title="DAY 5"></a>DAY 5</h3><p>  省选风波过去了，本来想着OI可以放一放了，学校开了运动会，mjl去济南集训了，cogs上一个邯郸一中的好友也问我要不要去济南，我就自己一人出发了，走上了自己的路。</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://kzime.xyz/2017/04/22/CF-410div2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kZime">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/l.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kZime's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/04/22/CF-410div2/" itemprop="url">CF#410div2</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-04-22T08:18:51+08:00">
                2017-04-22
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/04/22/CF-410div2/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2017/04/22/CF-410div2/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <p>这次比赛是真的开心，是在省选集训的时候和省实验的zf和mk一起打的，先是打到11点45， 然后跑到楼下创客活动室躲到比赛结束才会楼上机房，正准备继续写题的时候去组团上厕所的mk和zf突然跑回来让关灯躲起来，躲到凌晨1点才敢开灯，就直接去睡觉了。睡前和mk，zf聊了很多。</p>
<p><strong>真心祝愿MK学长省选进队！！</strong>（不是奶</p>
<p>明天就是省选了    </p>
<blockquote>
<p>JLOI, HEOI, HLOI, SHOI, SNOI, HAOI, SXOI, FJOI, LNOI, GZOI</p>
</blockquote>
<p><strong><em>BLESS ALL</em></strong></p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">while</span>(<span class="literal">true</span>) RP++;</div></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://kzime.xyz/2017/04/11/CF-408div2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kZime">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/l.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kZime's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/04/11/CF-408div2/" itemprop="url">CF#408div2</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-04-11T02:55:51+08:00">
                2017-04-11
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/04/11/CF-408div2/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2017/04/11/CF-408div2/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <p>第一次在晚上熬夜打CF，虽然准备的很充足，但还是只A了两道模拟，其中B题还被HACK掉了一次。。。经过mly的指点才把HACK点改掉，然后就是C，刚开始没思路，dalao们确认贪心可做之后就开始瞎JB贪了起来，然后WAWAWAWAWA。。。。<br>结果rating–<br>瘫</p>
<p>多做题吧，骚年</p>
<p>QAQ</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://kzime.xyz/2017/03/27/ha14摇杆监测/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kZime">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/l.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kZime's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/03/27/ha14摇杆监测/" itemprop="url">HAOI2014遥感监测题解</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-27T15:06:26+08:00">
                2017-03-27
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/题解/" itemprop="url" rel="index">
                    <span itemprop="name">题解</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/03/27/ha14摇杆监测/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2017/03/27/ha14摇杆监测/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <h1 id="HAOI2014-遥感监测"><a href="#HAOI2014-遥感监测" class="headerlink" title="[HAOI2014]遥感监测"></a><a href="#HAOI2014-遥感监测" title="[HAOI2014]遥感监测"></a><a href="http://cogs.pro/cogs/problem/problem.php?pid=1679" target="_blank" rel="external">[HAOI2014]遥感监测</a></h1><h2 id="题目描述"><a href="#题目描述" class="headerlink" title="题目描述"></a><a href="#题目描述" title="题目描述"></a>题目描述</h2><blockquote>
<p>外星人指的是地球以外的智慧生命。外星人长的是不是与地球上的人一样并不重要，但起码应该符合我们目前对生命基本形式的认识。比如，我们所知的任何生命都离不开液态水，并且都是基于化学元素碳（C）的有机分子组合成的复杂有机体。<br><a id="more"></a><br>ZDM实验室的天文学家们已经执著地观测ZDM-99星球十多年了，这个被称为“战神”的红色星球让他如此着迷。在过去的十多年中，他经常有一些令人激动的发现。ZDM-99星球表面有着明显的明暗变化。对这些明暗区域，天文学家们已经细致地研究了很多年，并且绘制出了较为详尽的地图，那些暗区是陆地，而亮区则是湖泊和海洋。他们一直坚信有水的地方，一定有生命的痕迹。</p>
<p>这天晚上的观测条件实在是空前的好，ZDM-99星球也十分明亮，不时呈现出若干个激光点，天文学家们推定这些激光点极有可能存在地球以外的智慧生命。遗憾的是仅持续很短的一段时间，这些激光点就消失了。</p>
<p>ZDM实验室的射电望远镜观测的区域有限，只可以遥感检测到一个半径为R的圆形区域。为了能同时能检测到所有的激光点，ZDM实验室需要要在一个水平的直线上尽快地安装多个的射电望远镜来。</p>
<p>不妨设，这条安放射电望远镜的水平直线为X轴，ZDM-99星球激光点就处在P1（x1,y1）P2(x2,y2)  ，…… ，Pn(xn,yn)。（忽略Z坐标）<br><a href="http://218.28.19.228/upload/image/20140718/20140718164645_17219.png" target="_blank" rel="external"><img src="http://218.28.19.228/upload/image/20140718/20140718164645_17219.png" alt=""></a><br>ZDM实验室的天文学家们想知道，至少需要安装多少个射电望远镜才能检测到所有激光点。</p>
</blockquote>
<h2 id="输入格式"><a href="#输入格式" class="headerlink" title="输入格式"></a><a href="#输入格式" title="输入格式"></a>输入格式</h2><blockquote>
<p>第1行:  N   R   分别表示激光点的个数和射电望远镜能检测到的半径<br>第2~N+1行： Xi  Yi      表示 激光点的坐标位置</p>
</blockquote>
<h2 id="输出格式"><a href="#输出格式" class="headerlink" title="输出格式"></a><a href="#输出格式" title="输出格式"></a>输出格式</h2><blockquote>
<p>输出一行： 最少需要安装的射电望远镜数。</p>
</blockquote>
<h2 id="样例输入"><a href="#样例输入" class="headerlink" title="样例输入"></a><a href="#样例输入" title="样例输入"></a>样例输入</h2><blockquote>
<p>3 2<br>1 2<br>-3 1<br>2 1</p>
</blockquote>
<h2 id="样例输出"><a href="#样例输出" class="headerlink" title="样例输出"></a><a href="#样例输出" title="样例输出"></a>样例输出</h2><blockquote>
<p>2</p>
</blockquote>
<h2 id="约束条件"><a href="#约束条件" class="headerlink" title="约束条件"></a><a href="#约束条件" title="约束条件"></a>约束条件</h2><blockquote>
<p>1≤R≤50     1≤N≤100   -1000≤ Xi  Yi ≤ 1000     | Yi | ≤ R<br>N，R, Xi  Yi都是整数。数据之间有一个空格。</p>
</blockquote>
<h2 id="题解"><a href="#题解" class="headerlink" title="题解"></a><a href="#题解" title="题解"></a>题解</h2><p>大概是个贪心，找出能保证包住最靠左的激光点的最靠右边的x轴坐标，但是枚举所以点时间复杂度明显太高，所以换一种思路，使用结构体处理出每个激光点所能被包住的可以作为望远镜的可行区间</p>
<p><a href="http://218.28.19.228/upload/image/20170327/20170327094625_62844.png" target="_blank" rel="external"><img src="http://218.28.19.228/upload/image/20170327/20170327094625_62844.png" alt=""></a><br>处理方法很简单<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</div><div class="line">	<span class="keyword">double</span> fan=<span class="built_in">sqrt</span>(<span class="built_in">pow</span>(r,<span class="number">2</span>)-<span class="built_in">pow</span>(p[i].y,<span class="number">2</span>));<span class="comment">//pow()是n次方函数pow(x,n)表示x的n次方</span></div><div class="line">	p[i].l=p[i].x-fan;</div><div class="line">	p[i].r=p[i].x+fan;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>然后对处理后的区间按照右端点进行排序(请同学们自主思考：为什么是右端点)然后进行统计<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">int</span> k=<span class="number">1</span>, ans=<span class="number">1</span>;</div><div class="line"><span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">2</span>;i&lt;=n;i++)&#123;</div><div class="line">	<span class="keyword">if</span>(p[i].l&lt;=p[k].r)&#123;<span class="comment">//p[k].r点可观测到点i</span></div><div class="line">		<span class="keyword">continue</span>;</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">else</span> &#123;<span class="comment">//更新k</span></div><div class="line">		k=i;</div><div class="line">		ans++;</div><div class="line">	&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>最后放一下全部代码</p>
<h2 id="代码实现"><a href="#代码实现" class="headerlink" title="代码实现"></a><a href="#代码实现" title="代码实现"></a>代码实现</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"></div><div class="line"><span class="keyword">int</span> ans,r,n;</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">int</span> <span class="title">read</span><span class="params">()</span></span>&#123;</div><div class="line">	<span class="keyword">int</span> k=<span class="number">0</span>,f=<span class="number">1</span>;<span class="keyword">char</span> c=getchar();</div><div class="line">	<span class="keyword">for</span>(;!<span class="built_in">isdigit</span>(c);c=getchar())<span class="keyword">if</span>(c==<span class="string">'-'</span>)f=<span class="number">-1</span>;</div><div class="line">	<span class="keyword">for</span>(;<span class="built_in">isdigit</span>(c);c=getchar())k=k*<span class="number">10</span>+c-<span class="string">'0'</span>;</div><div class="line">	<span class="keyword">return</span> k*f;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">mp</span>&#123;</span></div><div class="line"><span class="keyword">public</span>:</div><div class="line">	<span class="keyword">int</span> x;</div><div class="line">	<span class="keyword">int</span> y;</div><div class="line">	<span class="keyword">double</span> l;</div><div class="line">	<span class="keyword">double</span> r;</div><div class="line">&#125;p[<span class="number">2333</span>];</div><div class="line"></div><div class="line"><span class="function"><span class="keyword">bool</span> <span class="title">cmp</span><span class="params">(mp a,mp b)</span></span>&#123;</div><div class="line">	<span class="keyword">return</span> a.r&lt;b.r;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</div><div class="line">	freopen(<span class="string">"ha14a.in"</span>,<span class="string">"r"</span>,<span class="built_in">stdin</span>);</div><div class="line">	freopen(<span class="string">"ha14a.out"</span>,<span class="string">"w"</span>,<span class="built_in">stdout</span>);</div><div class="line">	n=read();</div><div class="line">	r=read();</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</div><div class="line">		p[i].x=read();</div><div class="line">		p[i].y=read();</div><div class="line">		<span class="keyword">if</span>(<span class="built_in">abs</span>(p[i].y)&gt;r)&#123;</div><div class="line">			<span class="built_in">cout</span>&lt;&lt;<span class="number">-1</span>;</div><div class="line">			<span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line"></div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</div><div class="line">		<span class="keyword">double</span> fan=<span class="built_in">sqrt</span>(<span class="built_in">pow</span>(r,<span class="number">2</span>)-<span class="built_in">pow</span>(p[i].y,<span class="number">2</span>));</div><div class="line">		p[i].l=p[i].x-fan;</div><div class="line">		p[i].r=p[i].x+fan;</div><div class="line">	&#125;</div><div class="line">	sort(p+<span class="number">1</span>,p+<span class="number">1</span>+n,cmp);</div><div class="line">	<span class="keyword">int</span> k=<span class="number">1</span>;</div><div class="line">	ans=<span class="number">1</span>;</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">2</span>;i&lt;=n;i++)&#123;</div><div class="line">		<span class="keyword">if</span>(p[i].l&lt;=p[k].r)&#123;</div><div class="line">			<span class="keyword">continue</span>;</div><div class="line">		&#125;</div><div class="line">		<span class="keyword">else</span> &#123;</div><div class="line">			k=i;</div><div class="line">			ans++;</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">	<span class="built_in">printf</span>(<span class="string">"%d"</span>,ans);</div><div class="line">	<span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://kzime.xyz/2017/03/25/12dora/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kZime">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/l.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kZime's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/03/25/12dora/" itemprop="url">纪念12Dora</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-25T15:11:32+08:00">
                2017-03-25
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/随笔/" itemprop="url" rel="index">
                    <span itemprop="name">随笔</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/03/25/12dora/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2017/03/25/12dora/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <p>“我所做的一切都是为了守护我亲爱的B站”。<br>        ———— 12dora</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://kzime.xyz/2017/03/20/HAOI2013题解/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kZime">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/l.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kZime's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2017/03/20/HAOI2013题解/" itemprop="url">HAOI2013题解</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-20T15:06:26+08:00">
                2017-03-20
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/题解/" itemprop="url" rel="index">
                    <span itemprop="name">题解</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/03/20/HAOI2013题解/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2017/03/20/HAOI2013题解/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        
          
            <p>HAOI2013   的特点</p>
<blockquote>
<p><del>题水</del></p>
</blockquote>
<p>谁说的。。。<br>做了大半年的题你跟我说水。。。<br>欸，似乎真的很水。。。<br>大概是我太水吧。。。</p>
<p><a id="more"></a></p>
<h2 id="T1-HAOI2013-跑步训练"><a href="#T1-HAOI2013-跑步训练" class="headerlink" title="T1 [HAOI2013] 跑步训练"></a><a href="#T1-HAOI2013-跑步训练" title="T1 [HAOI2013] 跑步训练"></a>T1 <a href="http://cogs.pro/cogs/problem/problem.php?pid=1368" target="_blank" rel="external">[HAOI2013] 跑步训练</a></h2><h3 id="题目描述"><a href="#题目描述" class="headerlink" title="题目描述"></a><a href="#题目描述" title="题目描述"></a>题目描述</h3><blockquote>
<p>Dr.Kong准备参加冬季越野比赛。为了能在比赛中有好的发挥，他决定每天早上上班前在附近的一条山路上开始训练。他当然希望每次训练中跑得尽可能远，但他的时间有限，每天早上跑步训练的时间不得超过M秒 (1 &lt;= M &lt;= 10,000,000)。<br>为了合理的安排跑步路程，Dr.Kong将整条山路划分成T个长度相同的小段(1 &lt;= T &lt;= 100,000)，并且，分别用u，f，d这3个字母之一来表示每个小段是上坡、平地，或是下坡。 Dr.Kong要花t1秒(1 &lt;= t1 &lt;= 100)才能跑完一段上坡路，跑完一段平地的耗时是<br>t2秒(1 &lt;= t2 &lt;= 100)，跑完一段下坡路要花t3秒(1 &lt;= t3 &lt;= 100)。注意，沿山路原路返回的时候，原本是上坡路的路段变成了下坡路，原本是下坡路的路段变成了上坡路。<br>  Dr.Kong想知道，在不超过M秒内返回的前提下，他最多能在这条山路上跑多远。</p>
</blockquote>
<h3 id="输入格式"><a href="#输入格式" class="headerlink" title="输入格式"></a><a href="#输入格式" title="输入格式"></a>输入格式</h3><blockquote>
<p>第1行:  M  T  t1  t2  t3  (数据之间用一个空格隔开)</p>
<p>第2..T+1行:  每行为1个字母u或f或d，描述了相应段的山路路况（上坡、平地，或是下坡）</p>
</blockquote>
<h3 id="输出格式"><a href="#输出格式" class="headerlink" title="输出格式"></a><a href="#输出格式" title="输出格式"></a>输出格式</h3><blockquote>
<p>输出1个整数，为Dr.Kong在不超时回到的前提下，最多能跑到几段。</p>
</blockquote>
<h3 id="样例输入"><a href="#样例输入" class="headerlink" title="样例输入"></a><a href="#样例输入" title="样例输入"></a>样例输入</h3><blockquote>
<p>13 5 3 2 1<br>u<br>f<br>u<br>d<br>f</p>
</blockquote>
<h3 id="样例输出"><a href="#样例输出" class="headerlink" title="样例输出"></a><a href="#样例输出" title="样例输出"></a>样例输出</h3><blockquote>
<p>3</p>
</blockquote>
<p> cogs评分半星。。。</p>
<h3 id="解法"><a href="#解法" class="headerlink" title="解法"></a><a href="#解法" title="解法"></a>解法</h3><p>   就是用一个整型s存达到当前步数要走的来回的耗时<br>       然后每走一段路程加上耗时与返回时的耗时，s &gt; M 并且step &lt;= t时结束程序，输出step - 1</p>
<h3 id="贴代码"><a href="#贴代码" class="headerlink" title="贴代码"></a><a href="#贴代码" title="贴代码"></a>贴代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/*kZime*/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> MAXN</span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">int</span> <span class="title">read</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">int</span> k = <span class="number">0</span>, f = <span class="number">1</span>; <span class="keyword">char</span> c = getchar();</div><div class="line">	<span class="keyword">for</span>(; !<span class="built_in">isdigit</span>(c); c = getchar())<span class="keyword">if</span>(c == <span class="string">'-'</span>) f = <span class="number">-1</span>;</div><div class="line">	<span class="keyword">for</span>(; <span class="built_in">isdigit</span>(c); c = getchar()) k = k * <span class="number">10</span> + c - <span class="string">'0'</span>;</div><div class="line">	<span class="keyword">return</span> k * f;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">char</span> <span class="title">in_char</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">char</span> c = getchar();</div><div class="line">	<span class="keyword">for</span>(; !<span class="built_in">isalpha</span>(c); c = getchar());</div><div class="line">	<span class="keyword">return</span> c;</div><div class="line">&#125;</div><div class="line">/-----------------------------------------------------------------------------*/</div><div class="line"><span class="keyword">int</span> v[<span class="number">3</span>] , m, t, s = <span class="number">0</span>, step = <span class="number">0</span>;<span class="comment">// v[3] 表示3种地形的速度</span></div><div class="line"><span class="keyword">char</span> c[<span class="number">100233</span>];</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MYLAB</span></div><div class="line">	freopen(<span class="string">"HAOI2013T1.in"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line">	freopen(<span class="string">"HAOI2013T1.out"</span>, <span class="string">"w"</span>, <span class="built_in">stdout</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">else</span></span></div><div class="line">	freopen(<span class="string">"in.txt"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></div><div class="line">	m = read();</div><div class="line">	t = read();</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i &lt;= <span class="number">2</span>; i++) &#123;</div><div class="line">		v[i] = read();</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; t; i++) &#123;</div><div class="line">		c[i] = in_char();</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">while</span>(s &lt;= m &amp;&amp; step &lt;= t) &#123;</div><div class="line">		<span class="keyword">if</span>(c[step] != <span class="string">'f'</span>) &#123; <span class="comment">// 如果step这一段地形不是平地，总耗时s增加v[0] + v[2]</span></div><div class="line">			s += v[<span class="number">0</span>] + v[<span class="number">2</span>];</div><div class="line">		&#125;</div><div class="line">		<span class="keyword">else</span> &#123;<span class="comment">//如果是平地，则总耗时增加两倍的平地耗时</span></div><div class="line">			s += v[<span class="number">1</span>] &lt;&lt; <span class="number">1</span>;</div><div class="line">		&#125;</div><div class="line">		step++;</div><div class="line">	&#125;</div><div class="line">	<span class="built_in">printf</span>(<span class="string">"%d"</span>,--step);</div><div class="line">	<span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h2 id="T2-HAOI2013-花卉节"><a href="#T2-HAOI2013-花卉节" class="headerlink" title="T2[HAOI2013] 花卉节"></a><a href="#T2-HAOI2013-花卉节" title="T2[HAOI2013] 花卉节"></a>T2<a href="http://cogs.pro/cogs/problem/problem.php?pid=1367" target="_blank" rel="external">[HAOI2013] 花卉节</a></h2><h3 id="题目描述-1"><a href="#题目描述-1" class="headerlink" title="题目描述"></a><a href="#题目描述-1" title="题目描述"></a>题目描述</h3><blockquote>
<p>ZZ市准备在绿博园举办一次花卉节。Dr.Kong接受到一个任务，要买一批花卉进行布置园林。<br>能投入买花卉的资金只有B元 (1 &lt;= B &lt;= 10^18) 。Dr.Kong决定做一个社会调查，统计一下市民们都喜欢哪种花卉，以便在有限的资金范围内，让更多的市民都能找到并标注一盆自己喜欢的花卉（一盆花只能一位市民标注）。<br>经调查统计，市场上有N (1 &lt;= N&lt;=100,000)种不同类型的花卉，第i种花卉的价格是Pi(1 &lt;= Pi &lt;= 10^18) 。有Ci (1 &lt;= Ci &lt;= 10^18) 个市民喜欢。<br>你能帮助Dr.Kong计算一下，在不透支的情况下，如何购买花卉才能让更多的市民都能找到并标注一盆自己喜欢的花卉？<br>例如：Dr.Kong 有 50块钱，有5种不同类型的花卉：<br><a href="http://218.28.19.228/upload/image/20170320/20170320172631_36113.png" target="_blank" rel="external"><img src="http://218.28.19.228/upload/image/20170320/20170320172631_36113.png" alt="HAOI2013T2"></a><br>显然，Dr.Kong不能购买第5种类型的花卉,因为他不够钱。<br>下面的购买方案是最优的：<br>第1种花卉买3盆；第2种花卉买1盆；第3种花卉买2盆；第4种花卉买2盆。<br>总共花费：5_3+1_1+10_2+7_2=50，这样，Dr.Kong 最多能让3+1+2+2 =8 人满意。</p>
</blockquote>
<h3 id="输入格式-1"><a href="#输入格式-1" class="headerlink" title="输入格式"></a><a href="#输入格式-1" title="输入格式"></a>输入格式</h3><blockquote>
<p>第1行:   N  B<br>第2..N+1行:  Pi Ci   （i=1，2，….，N）。</p>
</blockquote>
<h3 id="输出格式-1"><a href="#输出格式-1" class="headerlink" title="输出格式"></a><a href="#输出格式-1" title="输出格式"></a>输出格式</h3><blockquote>
<p>一个整数，最多可以让多少市民满意。</p>
</blockquote>
<h3 id="样例输入-1"><a href="#样例输入-1" class="headerlink" title="样例输入"></a><a href="#样例输入-1" title="样例输入"></a>样例输入</h3><blockquote>
<p>5 50<br>5 3<br>1 1<br>10 4<br>7 2<br>60 1</p>
</blockquote>
<h3 id="样例输出-1"><a href="#样例输出-1" class="headerlink" title="样例输出"></a><a href="#样例输出-1" title="样例输出"></a>样例输出</h3><blockquote>
<p>8</p>
</blockquote>
<h3 id="解法-1"><a href="#解法-1" class="headerlink" title="解法"></a><a href="#解法-1" title="解法"></a>解法</h3><p>算是一道很简单的贪心吧（是吧，反之就是很水，但因为要用到高精所以不水了（其实还是很水吧。。。<br>先将所有花的种类按照价格从小到大排序，然后尽可能多买便宜的花就行了，所以真的水<del>我也就WA了3遍</del></p>
<h3 id="贴代码-1"><a href="#贴代码-1" class="headerlink" title="贴代码"></a><a href="#贴代码-1" title="贴代码"></a>贴代码</h3><p>先把低精的代码贴上来</p>
<h4 id="低精50分版"><a href="#低精50分版" class="headerlink" title="低精50分版"></a><a href="#低精50分版" title="低精50分版"></a>低精50分版</h4><p><del>高精版随后贴上3/20/2017 6:30:43 PM</del><br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/*kZime*/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stack&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> MAXN 1000000</span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">int</span> <span class="title">read</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">int</span> k = <span class="number">0</span>, f = <span class="number">1</span>; <span class="keyword">char</span> c = getchar();</div><div class="line">	<span class="keyword">for</span>(; !<span class="built_in">isdigit</span>(c); c = getchar())<span class="keyword">if</span>(c == <span class="string">'-'</span>) f = <span class="number">-1</span>;</div><div class="line">	<span class="keyword">for</span>(; <span class="built_in">isdigit</span>(c); c = getchar()) k = k * <span class="number">10</span> + c - <span class="string">'0'</span>;</div><div class="line">	<span class="keyword">return</span> k * f;</div><div class="line">&#125;</div><div class="line"><span class="comment">/*-----------------------------------------------------------------------------*/</span></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">f</span>&#123;</span></div><div class="line">	<span class="keyword">int</span> p, w;</div><div class="line">&#125;fl[MAXN];</div><div class="line"><span class="keyword">int</span> n, m;</div><div class="line"><span class="function"><span class="keyword">bool</span> <span class="title">cmp</span><span class="params">(f a, f b)</span> </span>&#123;</div><div class="line">	<span class="keyword">return</span> a.w &lt; b.w;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MYLAB</span></div><div class="line">	freopen(<span class="string">"haoi13_t2.in"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line">	freopen(<span class="string">"haoi13_t2.out"</span>, <span class="string">"w"</span>, <span class="built_in">stdout</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">else</span></span></div><div class="line">	freopen(<span class="string">"in.txt"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></div><div class="line">	n = read();</div><div class="line">	m = read();</div><div class="line"></div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; n; i++) &#123;</div><div class="line">		fl[i].w = read();</div><div class="line">		fl[i].p = read();</div><div class="line">	&#125;</div><div class="line">	sort(fl, fl + n, cmp);</div><div class="line"></div><div class="line">	<span class="keyword">int</span> s = <span class="number">0</span>, i = <span class="number">0</span>, ans = <span class="number">0</span>;</div><div class="line">	<span class="keyword">while</span>(s &lt;= m &amp;&amp; i &lt; n) &#123;</div><div class="line">		<span class="keyword">int</span> temp = fl[i].p * fl[i].w;</div><div class="line">		<span class="keyword">if</span>(temp + s &lt; m) &#123;</div><div class="line">			s += temp;</div><div class="line">			ans += fl[i].p;</div><div class="line">			i++;</div><div class="line">		&#125;</div><div class="line">		<span class="keyword">else</span> &#123;</div><div class="line">			ans += (m - s) / fl[i].w;</div><div class="line">			<span class="keyword">break</span>;</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">	<span class="built_in">printf</span>(<span class="string">"%d"</span>, ans);</div><div class="line">	<span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h4 id="高精全A版"><a href="#高精全A版" class="headerlink" title="高精全A版"></a><a href="#高精全A版" title="高精全A版"></a>高精全A版</h4><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/*kZime*/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stack&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> MAXN 1000000</span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> ull unsigned long long</span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> ll long long  </span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"><span class="function">ull <span class="title">read</span><span class="params">()</span> </span>&#123;</div><div class="line">	ull k = <span class="number">0</span>, f = <span class="number">1</span>; <span class="keyword">char</span> c = getchar();</div><div class="line">	<span class="keyword">for</span>(; !<span class="built_in">isdigit</span>(c); c = getchar())<span class="keyword">if</span>(c == <span class="string">'-'</span>) f = <span class="number">-1</span>;</div><div class="line">	<span class="keyword">for</span>(; <span class="built_in">isdigit</span>(c); c = getchar()) k = k * <span class="number">10</span> + c - <span class="string">'0'</span>;</div><div class="line">	<span class="keyword">return</span> k * f;</div><div class="line">&#125;</div><div class="line"><span class="comment">/*-----------------------------------------------------------------------------*/</span></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">f</span>&#123;</span></div><div class="line">	ull p, w;</div><div class="line">&#125;fl[MAXN];</div><div class="line">ull n, m;</div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">bn</span>&#123;</span></div><div class="line"><span class="keyword">public</span>:</div><div class="line">	ull s[<span class="number">101</span>], l;</div><div class="line">	<span class="built_in">string</span> str;</div><div class="line">	bn() &#123;</div><div class="line">		<span class="built_in">memset</span>(s, <span class="number">0</span>, <span class="keyword">sizeof</span>(s));</div><div class="line">		l = <span class="number">1</span>;</div><div class="line">	&#125;</div><div class="line">	bn <span class="keyword">operator</span> + (<span class="keyword">const</span> ull &amp;b) &#123;</div><div class="line">		s[<span class="number">0</span>] += b;</div><div class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; l || s[i]; i++) &#123;</div><div class="line">			s[i + <span class="number">1</span>] += s[i] / <span class="number">10</span>;</div><div class="line">			s[i] %= <span class="number">10</span>;</div><div class="line">			<span class="keyword">if</span>(i &gt; l) l = i;</div><div class="line">		&#125;</div><div class="line">		l++;</div><div class="line">		<span class="keyword">while</span>(!s[l - <span class="number">1</span>]) l--;</div><div class="line">		<span class="keyword">return</span> *<span class="keyword">this</span>;</div><div class="line">	&#125;</div><div class="line"></div><div class="line">	<span class="function"><span class="keyword">void</span> <span class="title">output</span><span class="params">()</span> </span>&#123;</div><div class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> i = l - <span class="number">1</span>; i &gt;= <span class="number">0</span>; i--) &#123;</div><div class="line">			<span class="built_in">cout</span> &lt;&lt; (<span class="keyword">int</span>) s[i];</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;;</div><div class="line"><span class="function"><span class="keyword">bool</span> <span class="title">cmp</span><span class="params">(f a, f b)</span> </span>&#123;</div><div class="line">	<span class="keyword">return</span> a.w &lt; b.w;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MYLAB</span></div><div class="line">	freopen(<span class="string">"haoi13_t2.in"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line">	freopen(<span class="string">"haoi13_t2.out"</span>, <span class="string">"w"</span>, <span class="built_in">stdout</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">else</span></span></div><div class="line">	freopen(<span class="string">"in.txt"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></div><div class="line">	n = read();</div><div class="line">	m = read();</div><div class="line"></div><div class="line">	<span class="keyword">for</span>(ull i = <span class="number">0</span>; i &lt; n; i++) &#123;</div><div class="line">		fl[i].w = read();</div><div class="line">		fl[i].p = read();</div><div class="line">	&#125;</div><div class="line">	sort(fl, fl + n, cmp);</div><div class="line"></div><div class="line">	ull s = <span class="number">0</span>, i = <span class="number">0</span>;</div><div class="line">	bn ans;</div><div class="line">	<span class="keyword">while</span>(s &lt;= m &amp;&amp; i &lt; n) &#123;</div><div class="line">		ull temp = fl[i].p * fl[i].w;</div><div class="line">		<span class="keyword">if</span>(temp + s &lt; m) &#123;</div><div class="line">			s += temp;</div><div class="line">			ans = ans + fl[i].p;</div><div class="line">			i++;</div><div class="line">		&#125;</div><div class="line">		<span class="keyword">else</span> &#123;</div><div class="line">			ans = ans + (m - s) / fl[i].w;</div><div class="line">			<span class="keyword">break</span>;</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">	ans.output();</div><div class="line">	<span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h4 id="long-long-全A版"><a href="#long-long-全A版" class="headerlink" title="long long 全A版"></a><a href="#long-long-全A版" title="long long 全A版"></a>long long 全A版</h4><p>打完高精之后看了看天天的rank2代码突然发现不加高精也能过，然后就换了个结构自己码了一遍，但跑的还是没有天天的快，<strong>气哭</strong><br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/*kZime*/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stack&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> MAXN 1000000</span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> ll long long</span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"><span class="function"><span class="keyword">inline</span> ll <span class="title">read</span><span class="params">()</span> </span>&#123;</div><div class="line">	ll k = <span class="number">0</span>, f = <span class="number">1</span>; <span class="keyword">char</span> c = getchar();</div><div class="line">	<span class="keyword">for</span>(; !<span class="built_in">isdigit</span>(c); c = getchar())<span class="keyword">if</span>(c == <span class="string">'-'</span>) f = <span class="number">-1</span>;</div><div class="line">	<span class="keyword">for</span>(; <span class="built_in">isdigit</span>(c); c = getchar()) k = k * <span class="number">10</span> + c - <span class="string">'0'</span>;</div><div class="line">	<span class="keyword">return</span> k * f;</div><div class="line">&#125;</div><div class="line"><span class="comment">/*-----------------------------------------------------------------------------*/</span></div><div class="line"><span class="class"><span class="keyword">struct</span> <span class="title">f</span>&#123;</span></div><div class="line">	ll p, w;</div><div class="line">&#125;fl[MAXN];</div><div class="line">ll n, m;</div><div class="line"><span class="function"><span class="keyword">bool</span> <span class="title">cmp</span><span class="params">(f a, f b)</span> </span>&#123;</div><div class="line">	<span class="keyword">return</span> a.w &lt; b.w;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MYLAB</span></div><div class="line">	freopen(<span class="string">"haoi13_t2.in"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line">	freopen(<span class="string">"haoi13_t2.out"</span>, <span class="string">"w"</span>, <span class="built_in">stdout</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">else</span></span></div><div class="line">	freopen(<span class="string">"in.txt"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></div><div class="line">	n = read();</div><div class="line">	m = read();</div><div class="line"></div><div class="line">	<span class="keyword">for</span>(ll i = <span class="number">0</span>; i &lt; n; i++) &#123;</div><div class="line">		fl[i].w = read();</div><div class="line">		fl[i].p = read();</div><div class="line">	&#125;</div><div class="line">	sort(fl, fl + n, cmp);</div><div class="line"></div><div class="line">	ll i = <span class="number">0</span>, ans = <span class="number">0</span>;</div><div class="line">	<span class="keyword">while</span>(i &lt; n) &#123; <span class="comment">//花种类总数n 当前剩余可支配资金m</span></div><div class="line">		ll temp = m / fl[i].w; <span class="comment">//选择当前花种最多可以满足市民总数temp</span></div><div class="line">		<span class="keyword">if</span>(temp &gt; fl[i].p) &#123;</div><div class="line">			ans += fl[i].p;</div><div class="line">			m -= fl[i].p * fl[i].w;</div><div class="line">			i++;</div><div class="line">		&#125;</div><div class="line">		<span class="keyword">else</span> &#123;</div><div class="line">			ans += temp;</div><div class="line">			<span class="keyword">break</span>;</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">	<span class="built_in">printf</span>(<span class="string">"%lld"</span>, ans);</div><div class="line">	<span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="T3-HAOI2013-开关控制"><a href="#T3-HAOI2013-开关控制" class="headerlink" title="T3[HAOI2013] 开关控制"></a><a href="#T3-HAOI2013-开关控制" title="T3[HAOI2013] 开关控制"></a>T3<a href="http://cogs.pro/cogs/problem/problem.php?pid=1371" target="_blank" rel="external">[HAOI2013] 开关控制</a></h2><h3 id="题目描述-2"><a href="#题目描述-2" class="headerlink" title="题目描述"></a><a href="#题目描述-2" title="题目描述"></a>题目描述</h3><blockquote>
<p>元宵节快要到了，某城市人民公园将举办一次灯展。Dr.Kong准备设计出一个奇妙的展品，他计划将编号为1到N的N（1 &lt;= N &lt;= 35）盏灯放置在一个有M条（1 &lt;= M &lt;= 595）边连接的网络节点上。</p>
<p>   每盏灯上面都带有一個开关。当按下某一盏灯的开关時，这盏灯本身以及与之有边相连的灯的状态就会改变。状态改变指的是：当一盏灯是亮时，就会被关闭；当一盏灯是关闭时，就会被打开亮着。</p>
<p>现在的问题是，你能帮助Dr.Kong计算一下最少要按下多少个开关，才能把所有的灯都打开亮着（初始状态：所有的灯都是关闭的）。</p>
<p>数据保证至少有一种按开关的方案，使得所有的灯都能被重新打开。</p>
</blockquote>
<h3 id="输入格式-2"><a href="#输入格式-2" class="headerlink" title="输入格式"></a><a href="#输入格式-2" title="输入格式"></a>输入格式</h3><blockquote>
<p>第1行:   N  M<br>第2到第M+1行：每一行有两个由空格隔开的整數，表示两盏灯被一条边连接。</p>
</blockquote>
<h3 id="输出格式-2"><a href="#输出格式-2" class="headerlink" title="输出格式"></a><a href="#输出格式-2" title="输出格式"></a>输出格式</h3><blockquote>
<p>一个整数，表示要把所有的灯都打开时，最少需要按下的开关次数。</p>
</blockquote>
<h3 id="样例输入-2"><a href="#样例输入-2" class="headerlink" title="样例输入"></a><a href="#样例输入-2" title="样例输入"></a>样例输入</h3><blockquote>
<p>5 6<br>1 2<br>1 3<br>4 2<br>3 4<br>2 5<br>5 3</p>
</blockquote>
<h3 id="样例输出-2"><a href="#样例输出-2" class="headerlink" title="样例输出"></a><a href="#样例输出-2" title="样例输出"></a>样例输出</h3><blockquote>
<p>3</p>
</blockquote>
<h3 id="解法-2"><a href="#解法-2" class="headerlink" title="解法"></a><a href="#解法-2" title="解法"></a>解法</h3><p>听天天讲了好久终于搞明白怎么做了。。。<br>首先，证明每个灯按2次之后的的状态和按2次前的状态一样，因此<strong>每个灯最多按一次</strong>。<br>   其次，想要让保证当前灯的状态是亮着，前提条件是<strong>与这个灯相连的灯（包括当前灯）中有奇数个灯的按钮被按过</strong>。设g[i][j]表示灯i是否连接到灯j,x[i]表示i这个灯是否被按过。由这条性质，我们发现，可以列出一个方程(xor 为 异或^)<br>异或的性质：相同为0，不同为1<br><a href="http://218.28.19.228/upload/image/20170326/20170326223806_54672.png" target="_blank" rel="external"><img src="http://218.28.19.228/upload/image/20170326/20170326223806_54672.png" alt="异或方程组"></a><br>然后就是运用高斯消元，讲方程系数消到一个上三角矩阵。  代码实现<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= n; i++) &#123;<span class="comment">//循环的是列</span></div><div class="line">	free_yuan[i] = <span class="number">1</span>; <span class="comment">//初始化i行是自由元</span></div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> j = i; j &lt;= n; j++) &#123;<span class="comment">//从i~n循环行</span></div><div class="line">	    <span class="keyword">if</span>(!a[j][i]) <span class="keyword">continue</span>;<span class="comment">//如果第j行第i个系数为0，继续</span></div><div class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> k = i; k &lt;= n; k++) &#123;<span class="comment">//交换发现i行j行</span></div><div class="line">			swap(a[i][k], a[j][k]);</div><div class="line">		&#125;</div><div class="line">		swap(a[i][<span class="number">0</span>], a[j][<span class="number">0</span>]);<span class="comment">//a[i][0]存的是第i行的解（1），别人的代码可能是a[i][n + 1]</span></div><div class="line">		<span class="keyword">break</span>;</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">if</span>(!a[i][i]) <span class="keyword">continue</span>; <span class="comment">//这行存在有自由元</span></div><div class="line">	<span class="keyword">else</span> &#123;</div><div class="line">		free_yuan[i] = <span class="number">0</span>;</div><div class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> j = i + <span class="number">1</span>; j &lt;= n; j++) &#123;<span class="comment">//进行消元操作</span></div><div class="line">			<span class="keyword">if</span> (!a[j][i]) <span class="keyword">continue</span>;</div><div class="line">			<span class="keyword">for</span> (<span class="keyword">int</span> k = i; k &lt;= n; k++) a[j][k] ^= a[i][k];</div><div class="line">			a[j][<span class="number">0</span>] ^= a[i][<span class="number">0</span>];</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>消元之后，因为存在自由元的i行的灯xi可选择开，也可选择不开，因此要进行dfs找结果<br>代码实现<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">dfs</span><span class="params">(<span class="keyword">int</span> now, <span class="keyword">int</span> tmp)</span> </span>&#123;</div><div class="line">	<span class="keyword">if</span>(tmp &gt; ans) <span class="keyword">return</span>;</div><div class="line">	<span class="keyword">if</span>(now &lt;= <span class="number">0</span>) &#123;</div><div class="line">		ans = min(ans, tmp);</div><div class="line">		<span class="keyword">return</span>;</div><div class="line">	&#125;</div><div class="line">    <span class="comment">//深搜边界</span></div><div class="line">	<span class="keyword">if</span>(free_yuan[now]) &#123;<span class="comment">//如果now行为自由元</span></div><div class="line">		slt[now] = <span class="number">1</span>;</div><div class="line">		dfs(now - <span class="number">1</span>, tmp + <span class="number">1</span>);</div><div class="line">		slt[now] = <span class="number">0</span>;</div><div class="line">		dfs(now - <span class="number">1</span>, tmp);</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">else</span> &#123;<span class="comment">//slt[now]为灯now的状态</span></div><div class="line">		slt[now] = a[now][<span class="number">0</span>];</div><div class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> i = now + <span class="number">1</span>; i &lt;= n; i++) &#123;<span class="comment">//利用slt[now]化简now行之前的方程组</span></div><div class="line">			<span class="keyword">if</span> (a[now][i]) slt[now] ^= slt[i];</div><div class="line">		&#125;</div><div class="line">		dfs(now - <span class="number">1</span>, tmp + slt[now]);</div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</div><div class="line">    dfs(n, <span class="number">0</span>);</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="T4-HAOI2013-软件安装"><a href="#T4-HAOI2013-软件安装" class="headerlink" title="T4[HAOI2013] 软件安装"></a><a href="#T4-HAOI2013-软件安装" title="T4[HAOI2013] 软件安装"></a>T4<a href="http://cogs.pro/cogs/problem/problem.php?pid=1365" target="_blank" rel="external">[HAOI2013] 软件安装</a></h2><h3 id="解法-3"><a href="#解法-3" class="headerlink" title="解法"></a><a href="#解法-3" title="解法"></a>解法</h3><p>需要用到区间的查询与更改，所以自然而然的想到了线段树，但是困难的是线段树要维护什么。这道题要求查询符合长度要求的空区间的起始位置，所以要维护m：区间内最长空区间的长度，mp：区间最长空区间的起始位置。因为一定会有<strong>一段区间的最长空区间跨过两个子区间，而又不是两个子区间的最长空区间</strong>的情况，所以还要维护两个值lm：区间左端点之后的最长连续空区间的长度，rm：到右端点的最长连续空区间的长度。有了这4个值，才能对区间的最长空区间的起始位置进行查找。还有一点要注意的是因为<strong>优先选择左边的可行区间的起点</strong>，所以逻辑判断时候要考虑上这种情况。</p>
<h3 id="代码"><a href="#代码" class="headerlink" title="代码"></a><a href="#代码" title="代码"></a>代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/*kZime*/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stack&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> MAXN</span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">int</span> <span class="title">read</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">int</span> k = <span class="number">0</span>, f = <span class="number">1</span>; <span class="keyword">char</span> c = getchar();</div><div class="line">	<span class="keyword">for</span>(; !<span class="built_in">isdigit</span>(c); c = getchar())<span class="keyword">if</span>(c == <span class="string">'-'</span>) f = <span class="number">-1</span>;</div><div class="line">	<span class="keyword">for</span>(; <span class="built_in">isdigit</span>(c); c = getchar()) k = k * <span class="number">10</span> + c - <span class="string">'0'</span>;</div><div class="line">	<span class="keyword">return</span> k * f;</div><div class="line">&#125;</div><div class="line"><span class="comment">/*-----------------------------------------------------------------------------*/</span></div><div class="line"><span class="keyword">int</span> n, m;</div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">segtree</span> &#123;</span></div><div class="line"><span class="keyword">public</span>:</div><div class="line">	<span class="keyword">int</span> l, r, lm, rm, m, mp, tag; <span class="comment">//mp指的是最长区间的起始位置</span></div><div class="line">	segtree() &#123;</div><div class="line">		tag = <span class="number">-1</span>;</div><div class="line">	&#125;</div><div class="line">	<span class="function"><span class="keyword">void</span> <span class="title">in</span><span class="params">(<span class="keyword">int</span> _l, <span class="keyword">int</span> _r, <span class="keyword">int</span> _ml, <span class="keyword">int</span> _mr, <span class="keyword">int</span> _m, <span class="keyword">int</span> _mp, <span class="keyword">int</span> _tag)</span> </span>&#123;</div><div class="line">		l = _l;</div><div class="line">		r = _r;</div><div class="line">		lm = _ml;</div><div class="line">		rm = _mr;</div><div class="line">		m = _m;</div><div class="line">		mp = _mp;</div><div class="line">		tag = _tag;</div><div class="line">	&#125;</div><div class="line">&#125;nd[<span class="number">300050</span>];</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">build</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> l, <span class="keyword">int</span> r)</span> </span>&#123;</div><div class="line">	<span class="keyword">if</span>(l == r) &#123;</div><div class="line">		nd[x].in(l, r, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, l, <span class="number">-1</span>);</div><div class="line"> 	&#125;</div><div class="line">	<span class="keyword">else</span> &#123;</div><div class="line">		<span class="keyword">int</span> mid = (l + r) / <span class="number">2</span>;</div><div class="line">		<span class="keyword">int</span> len = r - l + <span class="number">1</span>;</div><div class="line">		build(x &lt;&lt; <span class="number">1</span>, l, mid);</div><div class="line">		build(x &lt;&lt; <span class="number">1</span> | <span class="number">1</span>, mid + <span class="number">1</span>, r);</div><div class="line">		nd[x].in(l, r, len, len, len, l, <span class="number">-1</span>);</div><div class="line">  	&#125;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">push_down</span><span class="params">(<span class="keyword">int</span> k)</span> </span>&#123;</div><div class="line">	<span class="keyword">if</span>(nd[k].tag == <span class="number">1</span>) &#123;<span class="comment">//该区间已被占满</span></div><div class="line">		nd[k].lm = nd[k].rm = nd[k].m = nd[k].mp = <span class="number">-1</span>;</div><div class="line">		nd[k &lt;&lt; <span class="number">1</span>].tag = <span class="number">1</span>;</div><div class="line">		nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].tag = <span class="number">1</span>;</div><div class="line">		nd[k].tag = <span class="number">-1</span>;</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">if</span>(nd[k].tag == <span class="number">0</span>) &#123;<span class="comment">//该区间为空区间</span></div><div class="line">		nd[k &lt;&lt; <span class="number">1</span>].tag = nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].tag = <span class="number">0</span>;</div><div class="line">		nd[k].lm = nd[k].rm = nd[k].m = (nd[k].r - nd[k].l + <span class="number">1</span>);</div><div class="line">		nd[k].mp = nd[k].l;</div><div class="line">		nd[k].tag = <span class="number">-1</span>;</div><div class="line">	&#125;</div><div class="line"></div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">push_up</span><span class="params">(<span class="keyword">int</span> k)</span> </span>&#123;</div><div class="line">	push_down(k);</div><div class="line">	push_down(k &lt;&lt; <span class="number">1</span>);</div><div class="line">	push_down(k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>);</div><div class="line">	<span class="keyword">int</span> x1 = nd[k &lt;&lt; <span class="number">1</span>].m , x2 = nd[k &lt;&lt; <span class="number">1</span>].rm + nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].lm, x3 = nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].m;</div><div class="line">	<span class="keyword">if</span>(x1 &gt;= x2 &amp;&amp; x1 &gt;= x3) &#123;         <span class="comment">// 注意！！！这三个判断是有优先级的</span></div><div class="line">		nd[k].m = x1;                  <span class="comment">// 优先级 x1 &gt; x2 &gt; x3</span></div><div class="line">		nd[k].mp = nd[k &lt;&lt; <span class="number">1</span>].mp;</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">else</span> <span class="keyword">if</span>(x2 &gt;= x3) &#123;</div><div class="line">		nd[k].m = x2;</div><div class="line">		nd[k].mp = nd[k &lt;&lt; <span class="number">1</span>].r - nd[k &lt;&lt; <span class="number">1</span>].rm + <span class="number">1</span>;</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">else</span> &#123;</div><div class="line">		nd[k].m = x3;</div><div class="line">		nd[k].mp = nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].mp;</div><div class="line">	&#125;</div><div class="line"></div><div class="line">	<span class="keyword">int</span> lenl = nd[k &lt;&lt; <span class="number">1</span>].r - nd[k &lt;&lt; <span class="number">1</span>].l + <span class="number">1</span>;</div><div class="line">	<span class="keyword">int</span> lenr = nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].r - nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].l + <span class="number">1</span>;</div><div class="line">	nd[k].lm = nd[k &lt;&lt; <span class="number">1</span>].lm;</div><div class="line">	<span class="keyword">if</span>(nd[k &lt;&lt; <span class="number">1</span>].lm == lenl) &#123;</div><div class="line">		nd[k].lm = max(nd[k].lm, nd[k &lt;&lt; <span class="number">1</span>].lm + nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].lm);<span class="comment">//一定要用max()函数，被占区间的rm可能为-1</span></div><div class="line">	&#125;</div><div class="line">    nd[k].rm = nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].rm;</div><div class="line">	<span class="keyword">if</span>(nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].rm == lenr) &#123;</div><div class="line">		nd[k].rm = max(nd[k].rm, nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].rm + nd[k &lt;&lt; <span class="number">1</span>].rm);    </div><div class="line">	&#125;</div><div class="line"></div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">query</span><span class="params">()</span> </span>&#123;</div><div class="line">	push_down(<span class="number">1</span>);</div><div class="line">	<span class="keyword">return</span> nd[<span class="number">1</span>].m;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">get_the_smallest_mp</span> <span class="params">(<span class="keyword">int</span> k, <span class="keyword">int</span> len)</span> </span>&#123;</div><div class="line">	push_down(k);</div><div class="line">	<span class="keyword">if</span>(nd[k].m &lt; len) <span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">	<span class="keyword">else</span> <span class="keyword">if</span>(nd[k].lm &gt;= len) <span class="keyword">return</span> nd[k].l;</div><div class="line">	<span class="keyword">else</span> <span class="keyword">if</span>(nd[k &lt;&lt; <span class="number">1</span>].m &gt;= len) <span class="keyword">return</span> get_the_smallest_mp(k &lt;&lt; <span class="number">1</span>, len);</div><div class="line">	<span class="keyword">else</span> <span class="keyword">if</span> (nd[k &lt;&lt; <span class="number">1</span>].rm &gt;= <span class="number">0</span> &amp;&amp; nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].lm &gt;= <span class="number">0</span> &amp;&amp; nd[k &lt;&lt; <span class="number">1</span>].rm + nd[k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>].lm &gt;= len) <span class="keyword">return</span> (nd[k &lt;&lt; <span class="number">1</span>].r - nd[k &lt;&lt; <span class="number">1</span>].rm + <span class="number">1</span>);</div><div class="line">	<span class="keyword">else</span> <span class="keyword">return</span> get_the_smallest_mp(k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>, len);</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">change</span><span class="params">(<span class="keyword">int</span> k, <span class="keyword">int</span> l, <span class="keyword">int</span> r, <span class="keyword">int</span> tag)</span> </span>&#123;  <span class="comment">//更新区间</span></div><div class="line">	push_down(k);</div><div class="line">	<span class="keyword">if</span>(l &lt;= nd[k].l &amp;&amp; nd[k].r &lt;= r) &#123;</div><div class="line">		nd[k].tag = tag;</div><div class="line">		<span class="keyword">return</span>;</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">else</span> <span class="keyword">if</span>(l &gt; nd[k].r || r &lt; nd[k].l) &#123;</div><div class="line">		<span class="keyword">return</span>;</div><div class="line">	&#125;</div><div class="line">	change(k &lt;&lt; <span class="number">1</span>, l, r, tag);</div><div class="line">	change(k &lt;&lt; <span class="number">1</span> | <span class="number">1</span>, l, r, tag);</div><div class="line">	push_up(k);</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MYLAB</span></div><div class="line">	freopen(<span class="string">"haoi13t4.in"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line">	freopen(<span class="string">"haoi13t4.out"</span>, <span class="string">"w"</span>, <span class="built_in">stdout</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">else</span></span></div><div class="line">	freopen(<span class="string">"in.txt"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></div><div class="line">	n = read();</div><div class="line">	m = read();</div><div class="line"></div><div class="line">	build(<span class="number">1</span>, <span class="number">1</span>, n);</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= m; i++) &#123;</div><div class="line">		<span class="keyword">int</span> type = read();</div><div class="line">		<span class="keyword">if</span>(type == <span class="number">1</span>) &#123;<span class="comment">//安装应用</span></div><div class="line">		    <span class="keyword">int</span> len = read();</div><div class="line">			<span class="keyword">if</span>(query() &lt; len) &#123;</div><div class="line">				<span class="built_in">printf</span>(<span class="string">"0\n"</span>);</div><div class="line">			&#125;</div><div class="line">			<span class="keyword">else</span> &#123;</div><div class="line">				<span class="keyword">int</span> sm =get_the_smallest_mp(<span class="number">1</span>, len);</div><div class="line">				<span class="built_in">printf</span>(<span class="string">"%d\n"</span>, sm);</div><div class="line">				change(<span class="number">1</span>, sm, sm + len - <span class="number">1</span>, <span class="number">1</span>);<span class="comment">//tag 1 表示占用该区间</span></div><div class="line">			&#125;</div><div class="line">		&#125;</div><div class="line">		<span class="keyword">else</span> &#123;</div><div class="line">			<span class="keyword">int</span> x = read();</div><div class="line">			<span class="keyword">int</span> len = read();</div><div class="line">			change(<span class="number">1</span>, x, x + len - <span class="number">1</span>, <span class="number">0</span>);<span class="comment">//tag 0 清空该区间</span></div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">	<span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h2 id="T5-HAOI2013-遥控器"><a href="#T5-HAOI2013-遥控器" class="headerlink" title="T5[HAOI2013] 遥控器"></a><a href="#T5-HAOI2013-遥控器" title="T5[HAOI2013] 遥控器"></a>T5<a href="http://cogs.pro/cogs/problem/problem.php?pid=1369" target="_blank" rel="external">[HAOI2013] 遥控器</a></h2><h3 id="解法-4"><a href="#解法-4" class="headerlink" title="解法"></a><a href="#解法-4" title="解法"></a>解法</h3><p>据说floyd也可以过，感觉好神奇，然而我打了一个模拟，要注意的细节很多<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/*kZime*/</span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;vector&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;queue&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stack&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdlib&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></div><div class="line"><span class="meta">#<span class="meta-keyword">define</span> MAXN</span></div><div class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</div><div class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">int</span> <span class="title">read</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">int</span> k = <span class="number">0</span>, f = <span class="number">1</span>; <span class="keyword">char</span> c = getchar();</div><div class="line">	<span class="keyword">for</span>(; !<span class="built_in">isdigit</span>(c); c = getchar())<span class="keyword">if</span>(c == <span class="string">'-'</span>) f = <span class="number">-1</span>;</div><div class="line">	<span class="keyword">for</span>(; <span class="built_in">isdigit</span>(c); c = getchar()) k = k * <span class="number">10</span> + c - <span class="string">'0'</span>;</div><div class="line">	<span class="keyword">return</span> k * f;</div><div class="line">&#125;</div><div class="line"><span class="comment">/*-----------------------------------------------------------------------------*/</span></div><div class="line"><span class="keyword">bool</span> num[<span class="number">10</span>], up, down, _, na[<span class="number">100</span>]; <span class="comment">// nc[i] （num cost）从x到i的最小代价</span></div><div class="line">							     	<span class="comment">// na[i] （num able）是否能到达i</span></div><div class="line"><span class="keyword">int</span> x, y, ans, nc[<span class="number">100</span>];</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">init</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>;i &lt;= <span class="number">3</span>; i++) &#123;</div><div class="line">		num[i] = read();</div><div class="line">	&#125;</div><div class="line">	up = read();</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">4</span>; i &lt;= <span class="number">6</span>; i++) &#123;</div><div class="line">		num[i] = read();</div><div class="line">	&#125;</div><div class="line">	down = read();</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">7</span>; i &lt;= <span class="number">9</span>; i++) &#123;</div><div class="line">		num[i] = read();</div><div class="line">	&#125;</div><div class="line">	_ = read();</div><div class="line">	num[<span class="number">0</span>] = read();</div><div class="line">	x = read();</div><div class="line">	y = read();</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">units</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i &lt;= <span class="number">9</span>; i++) &#123;</div><div class="line">		<span class="keyword">if</span>(num[i]) &#123;</div><div class="line">			nc[i] = <span class="number">1</span>;</div><div class="line">			na[i] = <span class="number">1</span>;</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">tens</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">if</span>(!_)<span class="keyword">return</span>;</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">1</span>; i &lt;= <span class="number">9</span>; i++) &#123;</div><div class="line">		<span class="keyword">if</span>(num[i]) &#123;</div><div class="line">			<span class="keyword">for</span>(<span class="keyword">int</span> j = <span class="number">1</span>; j &lt;= <span class="number">9</span>; j++) &#123;</div><div class="line">				<span class="keyword">if</span>(num[j]) &#123;</div><div class="line">					nc[i * <span class="number">10</span> + j] = <span class="number">3</span>;</div><div class="line">					na[i * <span class="number">10</span> + j] = <span class="number">1</span>;</div><div class="line">				&#125;</div><div class="line">			&#125;</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">dis_up</span><span class="params">(<span class="keyword">int</span> a, <span class="keyword">int</span> b)</span> </span>&#123;    <span class="comment">//从a一路up到b的代价</span></div><div class="line">	<span class="keyword">if</span>(b &gt;= a)<span class="keyword">return</span> b - a;</div><div class="line">	<span class="keyword">else</span> <span class="keyword">return</span> <span class="number">100</span> + b - a;  <span class="comment">//up到99后回到0</span></div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">dis_down</span><span class="params">(<span class="keyword">int</span> a, <span class="keyword">int</span> b)</span> </span>&#123;  <span class="comment">//从a一路down到b的代价</span></div><div class="line">	<span class="keyword">if</span>(a &gt;= b) <span class="keyword">return</span> a - b;</div><div class="line">	<span class="keyword">else</span> <span class="keyword">return</span> <span class="number">100</span> + a - b;  <span class="comment">//down到0后变成99</span></div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">try_num</span><span class="params">()</span> </span>&#123;              <span class="comment">//尝试从x直接到y</span></div><div class="line">	<span class="keyword">if</span>(na[y]) &#123;</div><div class="line">		ans = min(nc[y], ans);</div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">try_up</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">if</span>(!up) <span class="keyword">return</span>;</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i &lt;= <span class="number">99</span>; i++) &#123;</div><div class="line">		<span class="keyword">if</span>(na[i]) &#123;</div><div class="line">			ans = min(ans, nc[i] + dis_up(i, y));</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">try_down</span><span class="params">()</span> </span>&#123;</div><div class="line">	<span class="keyword">if</span>(!down) <span class="keyword">return</span>;</div><div class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i = <span class="number">0</span>; i &lt;= <span class="number">99</span>; i++) &#123;</div><div class="line">		<span class="keyword">if</span>(na[i]) &#123;</div><div class="line">			ans = min(ans, nc[i] + dis_down(i, y));</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;</div><div class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</div><div class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> MYLAB</span></div><div class="line">	freopen(<span class="string">"HAOI2013T5.in"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line">	freopen(<span class="string">"HAOI2013T5.out"</span>, <span class="string">"w"</span>, <span class="built_in">stdout</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">else</span></span></div><div class="line">	freopen(<span class="string">"in.txt"</span>, <span class="string">"r"</span>, <span class="built_in">stdin</span>);</div><div class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></div><div class="line">	ans = <span class="number">0x7fffffff</span>;</div><div class="line">	init();</div><div class="line">	units();</div><div class="line">	tens();</div><div class="line">	na[x] = <span class="number">1</span>;</div><div class="line">	nc[x] = <span class="number">0</span>;</div><div class="line">	try_num();</div><div class="line">	try_up();</div><div class="line">	try_down();</div><div class="line">	<span class="keyword">if</span>(ans == <span class="number">0x7fffffff</span>)<span class="built_in">printf</span>(<span class="string">"-1"</span>);</div><div class="line">	<span class="keyword">else</span> <span class="built_in">printf</span>(<span class="string">"%d"</span>, ans);</div><div class="line"></div><div class="line">	<span class="keyword">return</span> <span class="number">0</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="写在最后"><a href="#写在最后" class="headerlink" title="写在最后"></a><a href="#写在最后" title="写在最后"></a>写在最后</h2><p>话说模块化代码真爽啊</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/3/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
      <div id="sidebar-dimmer"></div>
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel sidebar-panel-active">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          
            <img class="site-author-image" itemprop="image"
              src="/images/l.png"
              alt="kZime" />
          
            <p class="site-author-name" itemprop="name">kZime</p>
            <p class="site-description motion-element" itemprop="description">我与我仍要大战三百回合, 闲杂人等都给我退后</p>
        </div>

        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
            
              <a href="/archivesb">
            
                <span class="site-state-item-count">18</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">9</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://www.zhihu.com/people/shang-di-zhi-li/activities" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-book"></i>
                  
                    
                      知乎
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://music.163.com/#/user/home?id=83525825" target="_blank" title="网易云音乐">
                  
                    <i class="fa fa-fw fa-music"></i>
                  
                    
                      网易云音乐
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://github.com/yourname" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                    
                      GitHub
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/yourname" target="_blank" title="BiliBili">
                  
                    <i class="fa fa-fw fa-television"></i>
                  
                    
                      BiliBili
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://steamcommunity.com/id/979617089" target="_blank" title="Steam">
                  
                    <i class="fa fa-fw fa-steam"></i>
                  
                    
                      Steam
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://t.me/kZime" target="_blank" title="Telegram">
                  
                    <i class="fa fa-fw fa-telegram"></i>
                  
                    
                      Telegram
                    
                </a>
              </span>
            
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              dalao们
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="https://blog.lcybox.com/" title="ChenYao" target="_blank">ChenYao</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://blog.xtybox.com/" title="XTT" target="_blank">XTT</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://blog.csdn.net/wmdcstdio/" title="cstdio" target="_blank">cstdio</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://fancypei.github.io/" title="Fancy" target="_blank">Fancy</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://sxysxy.org/" title="sxysxy" target="_blank">sxysxy</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://tys.design/" title="TYS" target="_blank">TYS</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://jjq0811.com/" title="JJQ" target="_blank">JJQ</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://dengspg.icoc.in/" title="DCH" target="_blank">DCH</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://justwb13.github.io/" title="WB" target="_blank">WB</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://wanzzhehe.github.io/" title="WZZ" target="_blank">WZZ</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/wahahaljy/" title="WAHAHA" target="_blank">WAHAHA</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.wingsec.win/" title="WH" target="_blank">WH</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.saruka.studio/" title="SARUKA" target="_blank">SARUKA</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://worldframe.top/" title="MCCC" target="_blank">MCCC</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://huangjiaming.com/" title="黄家面包" target="_blank">黄家面包</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://margatroid.xyz/" title="Entertainer" target="_blank">Entertainer</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2016 &mdash; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">kZime</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">
      
    </span>
  
</div>


  <div class="powered-by">由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动</div>

  <span class="post-meta-divider">|</span>

  <div class="theme-info">主题 &mdash; <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.2</div>


        







        
      </div>
    </footer>

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  






  
  







  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/three/three.min.js"></script>

  
  <script type="text/javascript" src="/lib/three/canvas_lines.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script>



  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>


  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>



  


  

    
      <script id="dsq-count-scr" src="https://kZime.disqus.com/count.js" async></script>
    

    

  













  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  

</body>
</html>
